Dynamic Recursion Pattern

نویسندگان

  • Gustavo Patow
  • Fernando Lyardet
  • Kent Beck
چکیده

Everybody knows what recursion is and how it should be implemented in a procedural language. The first analysis of recursion implementations is due Kent Beck [Beck92], but no formalization was given. The other work on an OOP implementation of the subject is due to Boby Wolf [Wolf97], but his work only deals with one aspect of the problem: Structural Recursion. Structural Recursion is a particular aspect of general recursion where the recursion is performed by a set of objects (a list or a tree, for example) that is already present in the computer memory. All the participating objects must exist previously the recursion starts. As opposite to Structural Recursion, Dynamic Recursion does not put such a strong requirement on the way the recursion is performed. This is done simply by delaying the creation of the recursive elements until they are actually needed, and thus, delaying the decision of finishing the recursion until its very end. Examples of recursion that can only be handled with this pattern are the famous eight-rook problem [HVC91] or even a simple airplane-routing problem. Another important point to be taken into account is that implementing recursive behavior into an object is more or less the same as forcing it to use a certain built-in iterator instead of using the iterator pattern [GoF]. Let's start by a simple, widely known example: sorting an array by the well known MergeSort Strategy (the analysis would be identical for the QuickSort strategy)[Baa91]. The traditional way to do so in procedural programming can be translated as is to OOP by creating a new message sort: in a MergeSort class:

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Recursion Schemes for Dynamic Programming

Dynamic programming is an algorithm design technique, which allows to improve efficiency by avoiding re-computation of identical subtasks. We present a new recursion combinator, dynamorphism, which captures the dynamic programming recursion pattern with memoization and identify some simple conditions when functions defined by structured general recursion can be redefined as a dynamorphism. The ...

متن کامل

Towards Tree Automata-based Success Types

Error detection facilities for dynamic languages are often based on unit testing. Thus, the advantage of rapid prototyping and flexibility must be weighed against cumbersome and time consuming test suite development. Lindahl and Sagonas’ success typings provide a means of static must-fail detection in Erlang. Due to the constraintbased nature of the approach, some errors involving nested tuples...

متن کامل

Locality Preserving Load Balancing with Provably Small Overhead

Parallelizing dynamic scientiic applications involves solving the dynamic load balancing problem. The balancing should take the communication requirements of the application into account. Many problems are dealing with objects in k-dimensional space with very special communication patterns. We describe a kind of an orthogonal recursive bisection clustering and show that its dynamic adaption inv...

متن کامل

What is Your Function? Static Pattern Matching on Function Behavior

We de ne a new notion of function pattern, which supports runtime pattern matching on functions based on their behavior. The ability to runtime dispatch on function type information enables new programmer expressiveness, including support of overloading on higherorder functions as well as other useful patterns. We formally present a type inference system for function patterns. The system answer...

متن کامل

Notes on Dynamic Programming Algorithms & Data Structures

The technique of Dynamic Programming (DP) could be described “recursion turned upside-down”. However, it is not usually used as an alternative to recursion. Rather, dynamic programming is used (if possible) for cases when a recurrence for an algorithmic problem will not run in polynomial-time if it is implemented recursively. So in fact Dynamic Programming is a morepowerful technique than basic...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2004